        $(function () {
				$.ajaxSetup({
					cache: false,
					headers: {
						"header":localStorage.getItem("token")
					}
				});
            $("#tt").datagrid({
            	idField : 'id',
            	title: "",
                url : basePath + "financial/page",
                width: "100%",  
                height: "400px",
                singleSelect : false, /* 是否选中一行 */
                pagination : true,/* 是否显示下面的分页菜单 */
                border:true,
                rowStyler: function() {
                	　　return 'height: 60px';
                	},
				onClickRow: function(e, rowIndex, rowData){
					$("#tt").datagrid("clearSelections");
				},
				onRowContextMenu: function(e, rowIndex, rowData) { //表头右键。选择要显示的列
					e.preventDefault(); //阻止浏览器捕获右键事件
					$(this).datagrid("clearSelections"); //取消所有选中项
					$(this).datagrid("selectRow", rowIndex); //根据索引选中该行
					$('#menu').menu('show', {
						left: e.pageX,//在鼠标点击处显示菜单
						top: e.pageY
					});
					e.preventDefault();  //阻止浏览器自带的右键菜单弹出
					$('#menu').menu({
						onClick: function(item) {
							var id = rowData.id.toString();//竞买人ID
							if (item.name == '001') {
								doDelete(id);
							} else if(item.name == '002') {
								toDetailDlg(id);
							} else if(item.name == '003') {
                                toRedemptionDlg(id);
							} else if(item.name == '004') {
								toCheckIncomeDlg(id);
							}
						}
					});
				},
                rownumbers:true,
                columns : [ [  {field : 'id', checkbox: false,hidden:true},
								{field : 'productName',title : '产品名称',width : '20%',align : 'center'},
								{field : 'interest',title : '最高年化利率(%)',width : '8%',align : 'center'},
								{field : 'deadline',title : '期限(天)',width : '8%',align : 'center'},
								{field : 'redemptionType',title : '赎回方式',width : '8%',align : 'center'},
								{field : 'buyMoney',title : '购买金额(元)',width : '8%',align : 'center'},
								{field : 'channel',title : '购买渠道',width : '10%',align : 'center'},
								{field : 'buyDate',title : '购买日期',width : '8%',align : 'center'},
								{field : 'income',title : '总收入',width : '8%',align : 'center'},
								{field : 'redemptionDate',title : '更新日期',width : '8%',align : 'center'},
								{field : 'keepDays',title : '持有天数',width : '8%',align : 'center'}
                ]],
            	loadMsg : '数据加载中,请稍候......'
            }); 
  
            var p = $('#tt').datagrid('getPager');  
            $(p).pagination({  
                /*
				 * 页数文本框前显示的汉字 修改每页默认条数 搜索pageList在jquery.easyui.min.js中修改，
				 * 分页区下拉分页数量集合和默认每页分页条数 striped属性 交替行换色
				 */  
                beforePageText: '第',  
                afterPageText: '页    共 {pages} 页',  
                displayMsg: '当前显示 {from}-{to} 条记录,共 {total} 条记录'  
            });

        }
        );
        // 搜索
        function doSearch() {
            $('#tt').datagrid('load', {  
            	buyDate1: $('#buyDate1').val(),
				buyDate2: $('#buyDate2').val(),
				state: $('#state').val(),
				channel: $('#channel').val()
			});
        }
        
        function clearQry() {
			//$("#measureTime1").datebox("setValue","");
			//$("#measureTime2").datebox("setValue","");
			$("#qryForm")[0].reset();
			doSearch();
		}

        // 新增框修改框弹出
        function add(){
        	var title = "新增";
            $('#addFinancialDlg').css("top","0").dialog({
                title: title,
                width: 1000,
                height: 400,
                closed: false,
                cache: false,
                href: basePath + 'navigator?page=/financial/add',
                modal: true
            });       	
        }

        // 新增
        function submitAddFinancial(){
			var v = $("#addff").form("validate");//验证通过为true
			if(!v){
				$.messager.alert('错误提示',"请填写完整信息!",'warning');
				return;
			}
			setBtnDisable("submitAddFinancialId");
			loadingProgress();
			$.ajax({
				type:"post",
				url:basePath+"financial/add",
				beforeSend: function(request) {
					request.setRequestHeader("header", localStorage.getItem("token"));
				},
				data : $('#addff').serializeArray(),
				cache:false,
				dataType: "json",
				success:function(result) {
					closeProgress();
					$.messager.show({
						title:'提示',
						msg:result.result,
						timeout:5000,
						showType:'slide'
					});
					cancelDlg("addFinancialDlg");
					$('#tt').datagrid('reload');// 刷新
				}
			});
        } 


        // 删除
        function doDelete(id) {
			$.messager.confirm('提示', '你确定要删除吗?',function(r){
				if(r){
					$.ajax({
						type:"delete",
						url:basePath + "financial/delete/" + id,
						cache:false,
						dataType: "json", // this is important
						success:function(result) {
							$.messager.show({
								title:'提示',
								msg:'删除成功',
								timeout:5000,
								showType:'slide'
							});
							$('#tt').datagrid('reload');// 刷新
							rows.length=0;
						}
					});
				}
			});
        }


        // 关闭弹窗
        function cancelDlg1(){
        	$('#addBloodSugarDlg').dialog("close");
        }
        //关闭弹窗
        function cancelDlg(dlgName){
        	$('#'+dlgName).dialog("close");
        }


		function toRedemptionDlg(id) {
			var title = "修改";
			$('#toRedemptionDlg').css("top","0").dialog({
				title: title,
				width: 400,
				height: 300,
				closed: false,
				cache: false,
				href: basePath+'navigator?page=/financial/redemption&id='+id,
				modal: true
			});
		}

		function toDetailDlg(id) {
			var title = "详情";
			$('#detailDlg').css("top","0").dialog({
				title: title,
				width: 1000,
				height: 400,
				closed: false,
				cache: false,
				href: basePath+'financial/navigator?page=/financial/detail&id='+id,
				modal: true
			});
		}

		function toCheckIncomeDlg(id,state) {
			$.ajax({
				type:"get",
				url:basePath + "financial/checkIncome/" + id,
				beforeSend: function(request) {
					request.setRequestHeader("header", localStorage.getItem("token"));
				},
				cache:false,
				dataType: "json",
				success:function(result) {
					$.messager.alert('SUCCESS',result.result,'SUCCESS');
				}
			});
		}
		
	function submitRedemption() {
        var v = $("#redemptionff").form("validate");//验证通过为true
        if(!v){
            $.messager.alert('错误提示',"请填写完整信息!",'warning');
            return;
        }
		$.ajax({
			type:"post",
			url:basePath+"financial/redemption",
			beforeSend: function(request) {
				request.setRequestHeader("header", localStorage.getItem("token"));
			},
			data : $('#redemptionff').serializeArray(),
			cache:false,
			dataType: "json",
			success:function(result) {
				$.messager.show({
					title:'提示',
					msg:result.result,
					timeout:5000,
					showType:'slide'
				});
				cancelDlg("toRedemptionDlg");
				$('#tt').datagrid('reload');// 刷新
			}
		});
	}


		function searchTotalIncome(){
			$.ajax({
				type:"get",
				url:basePath+"financial/searchTotalIncome",
				beforeSend: function(request) {
					request.setRequestHeader("header", localStorage.getItem("token"));
				},
				data : $('#applyff').serializeArray(),
				cache:false,
				dataType: "json",
				success:function(result) {
					$.messager.alert('SUCCESS',result.result,'SUCCESS');
				}
			});
		}

